package com.baidu.controller;

import com.baidu.entity.Product;
import com.baidu.service.ProductsService;
import com.baidu.utils.ResultResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
* @Description: 产品控制层
* @Author: 李亚丹
* @Date: 2021/12/13
*/
@RestController
@Slf4j
@CrossOrigin
public class ProductsController {
    @Autowired
    private ProductsService service;

    @PostMapping("findAll")
    public ResultResponse findAll(@RequestBody Product product) {
        log.info("查询列表");
        return service.findAll(product);
    }

    @PostMapping("saveProduct")
    public ResultResponse saveProduct(@RequestBody Product product){
        log.info("添加了{}商品状态值为0，待审核",product.getPname());
        return service.saveProduct(product);
    }

    @PostMapping("upProduct")
    public ResultResponse upProduct(@RequestBody Product product){
        log.info("{}产品执行力修改，状态更改为0待审核",product.getPname());
        return service.upProduct(product);
    }

    @PostMapping("delProduct")
    public ResultResponse delProduct(@RequestBody Product product){
        log.info("执行逻辑删除{}",product.getPid());
        return service.delProduct(product);
    }
}
